// $Id: multipart.h 76 2011-04-24 06:13:35Z cedric.shih@gmail.com $
/*
 * Copyright (C) 2011 Cedric Shih <cedric.shih@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef NIOHTTP_MULTIPART_H_
#define NIOHTTP_MULTIPART_H_

#ifdef __cplusplus
extern "C" {
#endif

struct niohttp_multipart_message {
	struct niohttp_headers *headers;
	struct niobuffer *content;
};

struct niohttp_multipart_decoder *niohttp_multipart_decoder_new(void);

void niohttp_multipart_decoder_free(struct niohttp_multipart_decoder *decoder);

int niohttp_multipart_decoder_setup(struct niohttp_multipart_decoder *decoder,
		const char *boundary);

void niohttp_multipart_decoder_reset(struct niohttp_multipart_decoder *decoder);

void niohttp_multipart_decoder_teardown(
		struct niohttp_multipart_decoder *decoder);

int niohttp_multipart_decoder_parse(struct niohttp_multipart_decoder *decoder,
		struct niobuffer *buffer,
		struct niohttp_multipart_message **message);

struct niohttp_multipart_encoder *niohttp_multipart_encoder_new(void);

void niohttp_multipart_encoder_free(struct niohttp_multipart_encoder *encoder);

int niohttp_multipart_encoder_setup(struct niohttp_multipart_encoder *encoder,
		struct niohttp_headers *headers);

void niohttp_multipart_encoder_teardown(
		struct niohttp_multipart_encoder *encoder);

int niohttp_multipart_encoder_format(struct niohttp_multipart_encoder *encoder,
		struct niobuffer *buffer);

#ifdef __cplusplus
}
#endif

#endif /* NIOHTTP_MULTIPART_H_ */
